﻿@model OT.Areas.Admin.Models.ChangePass
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm())
{  
    @Html.ValidationSummary(true)
    <div class="form-horizontal">
        <div id="divMsgIndex" style="text-align: center;"></div>
    </div>
    <div class="admin-form" style="margin-top: 0px;">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div class="widget wred">
                        <div class="widget-head">
                            <i class="fa fa-lock"></i>Change PassWord 
                        </div>
                        <div class="widget-content">
                            <div class="padd">
                                <div class="form-horizontal">
                                    <div class="form-group" id="divpass">
                                        <label class="control-label col-lg-4" for="inputEmail">old Password</label>
                                        <div class="col-lg-7">
                                            <input class="form-control" placeholder="Enter Current Password" type="password" id="Password">
                                        </div>
                                    </div>
                                    <div class="form-group" id="divnewpass">
                                        <label class="control-label col-lg-4" for="inputPassword">New Password</label>
                                        <div class="col-lg-7">
                                            <input class="form-control" placeholder="Enter New Password" type="password" id="NewPassword">
                                        </div>
                                    </div>
                                    <div class="form-group" id="divconfpass">
                                        <label class="control-label col-lg-4" for="inputEmail">Re-Enter Password</label>
                                        <div class="col-lg-7 control-label">
                                            <input class="form-control" placeholder="Re-Enter New Password" type="password" id="ConfirmPassword">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="widget-foot">
                            <div class="col-lg-8"></div>
                            <button type="button" class="btn btn-sm btn-default" id="change">Change</button>
                            <button type="reset" class="btn btn-default btn-sm">Reset</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
}
<script type="text/javascript">
    $(document).ready(function () {
        $('#h2Title').html("<i class='fa fa-key'></i>  Change PassWord");
        $('#aTitle').html("Change PassWord");
    });
    $("#change").click(function (e) {
        var Password = $("#Password").val();
        var NewPassword = $("#NewPassword").val();
        var ConfirmPassword = $("#ConfirmPassword").val();
        if (Password == '' || NewPassword == '' || ConfirmPassword == '') {
            showMsg("divMsgIndex", "Enter The Value of Required Field !!", "danger");
            (Password == '') ? $('#divpass').addClass('has-error') : $('#divpass').removeClass('has-error');
            (NewPassword == '') ? $('#divnewpass').addClass('has-error') : $('#divnewpass').removeClass('has-error');
            (ConfirmPassword == '') ? $('#divconfpass').addClass('has-error') : $('#divconfpass').removeClass('has-error');
        }
        else if (NewPassword != ConfirmPassword) {
            showMsg("divMsgIndex", "Confirm Password Not Matched !!", "danger");
        }
        else {
            $.ajax({
                url: "/Admin/ChangePass/Index?Password=" + Password + "&NewPassword=" + NewPassword + "&ConfirmPassword=" + ConfirmPassword,
                type: "POST",
                success: function (result) {
                    if (result != "NotValid") {
                        $('#modalDiv').modal('hide');
                        showMsg("divMsgIndex", "Password Reset Successfuly", "success");
                    }
                    else {
                        showMsg("divMsgIndex", "Password Not Changed !!", "danger");
                    }
                },
                error: function (data) {
                }
            });
        }
    });
</script>
